/**
 * 通用方法封装处理
 * Copyright (c) 2019 ruoyi 
 */
$(function () {

    //  layer扩展皮肤
    if (window.layer !== undefined) {
        layer.config({
            extend: 'moon/style.css',
            skin: 'layer-ext-moon'
        });
    }

    // 回到顶部绑定
    if ($.fn.toTop !== undefined) {
        $('#scroll-up').toTop();
    }

    // select2复选框事件绑定
    if ($.fn.select2 !== undefined) {
        $.fn.select2.defaults.set("theme", "bootstrap");
        $("select.form-control:not(.noselect2)").each(function () {
            $(this).select2().on("change", function () {
                $(this).valid();
            })
        })
    }

    // iCheck单选框及复选框事件绑定
    if ($.fn.iCheck !== undefined) {
        $(".check-box:not(.noicheck),.radio-box:not(.noicheck)").each(function () {
            $(this).iCheck({
                checkboxClass: 'icheckbox-blue',
                radioClass: 'iradio-blue',
            })
        })
    }

    // 气泡弹出框特效（移到元素时）
    $(document).on("mouseenter", '.table [data-toggle="popover"]', function () {
        var _this = this;
        $(this).popover("show");
        $(".popover").on("mouseleave", function () {
            $(_this).popover('hide');
        });
    })

    // 气泡弹出框特效（离开元素时）
    $(document).on("mouseleave", '.table [data-toggle="popover"]', function () {
        var _this = this;
        setTimeout(function () {
            if (!$(".popover:hover").length) $(_this).popover("hide");
        }, 100);
    });

    // 取消回车自动提交表单
    $(document).on("keypress", ":input:not(textarea):not([type=submit])", function (event) {
        if (event.keyCode == 13) {
            event.preventDefault();
        }
    });

    // laydate 时间控件绑定
    if ($(".select-time").length > 0) {
        layui.use('laydate', function () {
            var laydate = layui.laydate;
            var startDate = laydate.render({
                elem: '#startTime',
                max: $('#endTime').val(),
                theme: 'molv',
                trigger: 'click',
                done: function (value, date) {
                    // 结束时间大于开始时间
                    if (value !== '') {
                        endDate.config.min.year = date.year;
                        endDate.config.min.month = date.month - 1;
                        endDate.config.min.date = date.date;
                    } else {
                        endDate.config.min.year = '';
                        endDate.config.min.month = '';
                        endDate.config.min.date = '';
                    }
                }
            });
            var endDate = laydate.render({
                elem: '#endTime',
                min: $('#startTime').val(),
                theme: 'molv',
                trigger: 'click',
                done: function (value, date) {
                    // 开始时间小于结束时间
                    if (value !== '') {
                        startDate.config.max.year = date.year;
                        startDate.config.max.month = date.month - 1;
                        startDate.config.max.date = date.date;
                    } else {
                        startDate.config.max.year = '2099';
                        startDate.config.max.month = '12';
                        startDate.config.max.date = '31';
                    }
                }
            });
        });
    }

    // laydate time-input 时间控件绑定
    if ($(".time-input").length > 0) {
        layui.use('laydate', function () {
            var com = layui.laydate;
            $(".time-input").each(function (index, item) {
                var time = $(item);
                // 控制控件外观
                var type = time.attr("data-type") || 'date';
                // 控制回显格式
                var format = time.attr("data-format") || 'yyyy-MM-dd';
                // 控制日期控件按钮
                var buttons = time.attr("data-btn") || 'clear|now|confirm', newBtnArr = [];
                // 日期控件选择完成后回调处理
                var callback = time.attr("data-callback") || {};
                if (buttons) {
                    if (buttons.indexOf("|") > 0) {
                        var btnArr = buttons.split("|"), btnLen = btnArr.length;
                        for (var j = 0; j < btnLen; j++) {
                            if ("clear" === btnArr[j] || "now" === btnArr[j] || "confirm" === btnArr[j]) {
                                newBtnArr.push(btnArr[j]);
                            }
                        }
                    } else {
                        if ("clear" === buttons || "now" === buttons || "confirm" === buttons) {
                            newBtnArr.push(buttons);
                        }
                    }
                } else {
                    newBtnArr = ['clear', 'now', 'confirm'];
                }
                com.render({
                    elem: item,
                    theme: 'molv',
                    trigger: 'click',
                    type: type,
                    format: format,
                    btns: newBtnArr,
                    done: function (value, data) {
                        if (typeof window[callback] != 'undefined'
                            && window[callback] instanceof Function) {
                            window[callback](value, data);
                        }
                    }
                });
            });
        });
    }

    // tree 关键字搜索绑定
    if ($("#keyword").length > 0) {
        $("#keyword").bind("focus", function focusKey(e) {
            if ($("#keyword").hasClass("empty")) {
                $("#keyword").removeClass("empty");
            }
        }).bind("blur", function blurKey(e) {
            if ($("#keyword").val() === "") {
                $("#keyword").addClass("empty");
            }
            $.tree.searchNode(e);
        }).bind("input propertychange", $.tree.searchNode);
    }

    // tree表格树 展开/折叠
    var expandFlag;
    $("#expandAllBtn").click(function () {
        var dataExpand = $.common.isEmpty(table.options.expandAll) ? true : table.options.expandAll;
        expandFlag = $.common.isEmpty(expandFlag) ? dataExpand : expandFlag;
        if (!expandFlag) {
            $.bttTable.bootstrapTreeTable('expandAll');
        } else {
            $.bttTable.bootstrapTreeTable('collapseAll');
        }
        expandFlag = expandFlag ? false : true;
    })

    // 按下ESC按钮关闭弹层
    $('body', document).on('keyup', function (e) {
        if (e.which === 27) {
            $.modal.closeAll();
        }
    });
});

(function ($) {
    'use strict';
    $.fn.toTop = function (opt) {
        var elem = this;
        var win = (opt && opt.hasOwnProperty('win')) ? opt.win : $(window);
        var doc = (opt && opt.hasOwnProperty('doc')) ? opt.doc : $('html, body');
        var options = $.extend({
            autohide: true,
            offset: 50,
            speed: 500,
            position: true,
            right: 15,
            bottom: 5
        }, opt);
        elem.css({
            'cursor': 'pointer'
        });
        if (options.autohide) {
            elem.css('display', 'none');
        }
        if (options.position) {
            elem.css({
                'position': 'fixed',
                'right': options.right,
                'bottom': options.bottom,
            });
        }
        elem.click(function () {
            doc.animate({
                scrollTop: 0
            }, options.speed);
        });
        win.scroll(function () {
            var scrolling = win.scrollTop();
            if (options.autohide) {
                if (scrolling > options.offset) {
                    elem.fadeIn(options.speed);
                } else elem.fadeOut(options.speed);
            }
        });
    };
})(jQuery);

/** 刷新选项卡 */
var refreshItem = function () {
    var topWindow = $(window.parent.document);
    var currentId = $('.page-tabs-content', topWindow).find('.active').attr('data-id');
    var target = $('.RuoYi_iframe[data-id="' + currentId + '"]', topWindow);
    var url = target.attr('src');
    target.attr('src', url).ready();
}

/** 关闭选项卡 */
var closeItem = function (dataId) {
    var topWindow = $(window.parent.document);
    if ($.common.isNotEmpty(dataId)) {
        window.parent.$.modal.closeLoading();
        // 根据dataId关闭指定选项卡
        $('.menuTab[data-id="' + dataId + '"]', topWindow).remove();
        // 移除相应tab对应的内容区
        $('.mainContent .RuoYi_iframe[data-id="' + dataId + '"]', topWindow).remove();
        return;
    }
    var panelUrl = window.frameElement.getAttribute('data-panel');
    $('.page-tabs-content .active i', topWindow).click();
    if ($.common.isNotEmpty(panelUrl)) {
        $('.menuTab[data-id="' + panelUrl + '"]', topWindow).addClass('active').siblings('.menuTab').removeClass('active');
        $('.mainContent .RuoYi_iframe', topWindow).each(function () {
            if ($(this).data('id') == panelUrl) {
                $(this).show().siblings('.RuoYi_iframe').hide();
                return false;
            }
        });
    }
}

/** 关闭选项卡 */
var closeItem2 = function (dataId) {
    var topWindow = $(window.parent.document);
    if (dataId!=null && dataId!='') {
        window.parent.$.modal.closeLoading();
        // 根据dataId关闭指定选项卡
        $('.menuTab[data-id="' + dataId + '"]', topWindow).remove();
        // 移除相应tab对应的内容区
        $('.mainContent .RuoYi_iframe[data-id="' + dataId + '"]', topWindow).remove();
        return;
    }
    var panelUrl = window.frameElement.getAttribute('data-panel');
    $('.page-tabs-content .active i', topWindow).click();
    if ($.common.isNotEmpty(panelUrl)) {
        $('.menuTab[data-id="' + panelUrl + '"]', topWindow).addClass('active').siblings('.menuTab').removeClass('active');
        $('.mainContent .RuoYi_iframe', topWindow).each(function () {
            if ($(this).data('id') == panelUrl) {
                $(this).show().siblings('.RuoYi_iframe').hide();
                return false;
            }
        });
    }
}

/** 创建选项卡 */
function createMenuItem(dataUrl, menuName, isRefresh) {
    var panelUrl = window.frameElement.getAttribute('data-id');
    dataIndex = $.common.random(1, 100),
        flag = true;
    if (dataUrl == undefined || $.trim(dataUrl).length == 0) return false;
    var topWindow = $(window.parent.document);
    // 选项卡菜单已存在
    $('.menuTab', topWindow).each(function () {
        if ($(this).data('id') == dataUrl) {
            if (!$(this).hasClass('active')) {
                $(this).addClass('active').siblings('.menuTab').removeClass('active');
                scrollToTab(this);
                $('.page-tabs-content').animate({ marginLeft: "" }, "fast");
                // 显示tab对应的内容区
                $('.mainContent .RuoYi_iframe', topWindow).each(function () {
                    if ($(this).data('id') == dataUrl) {
                        $(this).show().siblings('.RuoYi_iframe').hide();
                        return false;
                    }
                });
            }
            if (isRefresh) {
                refreshTab();
            }
            flag = false;
            return false;
        }
    });
    // 选项卡菜单不存在
    if (flag) {
        var str = '<a href="javascript:;" class="active menuTab noactive" data-id="' + dataUrl + '" data-panel="' + panelUrl + '">' + menuName + ' <i class="fa fa-times-circle"></i></a>';
        $('.menuTab', topWindow).removeClass('active');

        // 添加选项卡对应的iframe
        var str1 = '<iframe class="RuoYi_iframe" name="iframe' + dataIndex + '" width="100%" height="100%" src="' + dataUrl + '" frameborder="0" data-id="' + dataUrl + '" data-panel="' + panelUrl + '" seamless></iframe>';
        $('.mainContent', topWindow).find('iframe.RuoYi_iframe').hide().parents('.mainContent').append(str1);

        window.parent.$.modal.loading("数据加载中，请稍后...");
        $('.mainContent iframe:visible', topWindow).load(function () {
            window.parent.$.modal.closeLoading();
        });

        // 添加选项卡
        $('.menuTabs .page-tabs-content', topWindow).append(str);
        scrollToTab($('.menuTab.active', topWindow));
    }
    return false;
}

// 刷新iframe
function refreshTab() {
    var topWindow = $(window.parent.document);
    var currentId = $('.page-tabs-content', topWindow).find('.active').attr('data-id');
    var target = $('.RuoYi_iframe[data-id="' + currentId + '"]', topWindow);
    var url = target.attr('src');
    target.attr('src', url).ready();
}

// 滚动到指定选项卡
function scrollToTab(element) {
    var topWindow = $(window.parent.document);
    var marginLeftVal = calSumWidth($(element).prevAll()),
        marginRightVal = calSumWidth($(element).nextAll());
    // 可视区域非tab宽度
    var tabOuterWidth = calSumWidth($(".content-tabs", topWindow).children().not(".menuTabs"));
    //可视区域tab宽度
    var visibleWidth = $(".content-tabs", topWindow).outerWidth(true) - tabOuterWidth;
    //实际滚动宽度
    var scrollVal = 0;
    if ($(".page-tabs-content", topWindow).outerWidth() < visibleWidth) {
        scrollVal = 0;
    } else if (marginRightVal <= (visibleWidth - $(element).outerWidth(true) - $(element).next().outerWidth(true))) {
        if ((visibleWidth - $(element).next().outerWidth(true)) > marginRightVal) {
            scrollVal = marginLeftVal;
            var tabElement = element;
            while ((scrollVal - $(tabElement).outerWidth()) > ($(".page-tabs-content", topWindow).outerWidth() - visibleWidth)) {
                scrollVal -= $(tabElement).prev().outerWidth();
                tabElement = $(tabElement).prev();
            }
        }
    } else if (marginLeftVal > (visibleWidth - $(element).outerWidth(true) - $(element).prev().outerWidth(true))) {
        scrollVal = marginLeftVal - $(element).prev().outerWidth(true);
    }
    $('.page-tabs-content', topWindow).animate({ marginLeft: 0 - scrollVal + 'px' }, "fast");
}

//计算元素集合的总宽度
function calSumWidth(elements) {
    var width = 0;
    $(elements).each(function () {
        width += $(this).outerWidth(true);
    });
    return width;
}

/** 密码规则范围验证 */
function checkpwd(chrtype, password) {
    if (chrtype == 1) {
        if (!$.common.numValid(password)) {
            $.modal.alertWarning("密码只能为0-9数字");
            return false;
        }
    } else if (chrtype == 2) {
        if (!$.common.enValid(password)) {
            $.modal.alertWarning("密码只能为a-z和A-Z字母");
            return false;
        }
    } else if (chrtype == 3) {
        if (!$.common.enNumValid(password)) {
            $.modal.alertWarning("密码必须包含字母以及数字");
            return false;
        }
    } else if (chrtype == 4) {
        if (!$.common.charValid(password)) {
            $.modal.alertWarning("密码必须包含字母、数字、以及特殊符号<font color='red'>~!@#$%^&*()-=_+</font>");
            return false;
        }
    }
    return true;
}

// 日志打印封装处理
var log = {
    log: function (msg) {
        console.log(msg);
    },
    info: function (msg) {
        console.info(msg);
    },
    warn: function (msg) {
        console.warn(msg);
    },
    error: function (msg) {
        console.error(msg);
    }
};

// 本地缓存处理
var storage = {
    set: function (key, value) {
        window.localStorage.setItem(key, value);
    },
    get: function (key) {
        return window.localStorage.getItem(key);
    },
    remove: function (key) {
        window.localStorage.removeItem(key);
    },
    clear: function () {
        window.localStorage.clear();
    }
};

// 主子表操作封装处理
var sub = {
    editColumn: function () {
        var dataColumns = [];
        for (var columnIndex = 0; columnIndex < table.options.columns.length; columnIndex++) {
            if (table.options.columns[columnIndex].visible != false) {
                dataColumns.push(table.options.columns[columnIndex]);
            }
        }
        var params = new Array();
        var data = $("#" + table.options.id).bootstrapTable('getData');
        var count = data.length;
        for (var dataIndex = 0; dataIndex < count; dataIndex++) {
            var columns = $('#' + table.options.id + ' tr[data-index="' + dataIndex + '"] td');
            var obj = new Object();
            for (var i = 0; i < columns.length; i++) {
                var inputValue = $(columns[i]).find('input');
                var selectValue = $(columns[i]).find('select');
                var key = dataColumns[i].field;
                if ($.common.isNotEmpty(inputValue.val())) {
                    obj[key] = inputValue.val();
                } else if ($.common.isNotEmpty(selectValue.val())) {
                    obj[key] = selectValue.val();
                } else {
                    obj[key] = "";
                }
            }
            var item = data[dataIndex];
            var extendObj = $.extend({}, item, obj);
            params.push({ index: dataIndex, row: extendObj });
        }
        $("#" + table.options.id).bootstrapTable("updateRow", params);
    },
    delColumn: function (column) {
        sub.editColumn();
        var subColumn = $.common.isEmpty(column) ? "index" : column;
        var ids = $.table.selectColumns(subColumn);
        if (ids.length == 0) {
            $.modal.alertWarning("请至少选择一条记录");
            return;
        }
        $("#" + table.options.id).bootstrapTable('remove', { field: subColumn, values: ids });
    },
    addColumn: function (row, tableId) {
        var currentId = $.common.isEmpty(tableId) ? table.options.id : tableId;
        table.set(currentId);
        var count = $("#" + currentId).bootstrapTable('getData').length;
        sub.editColumn();
        $("#" + currentId).bootstrapTable('insertRow', {
            index: count + 1,
            row: row
        });
    }
};

// 动态加载css文件
function loadCss(file, headElem) {
    var link = document.createElement('link');
    link.href = file;
    link.rel = 'stylesheet';
    link.type = 'text/css';
    if (headElem) headElem.appendChild(link);
    else document.getElementsByTagName('head')[0].appendChild(link);
}

// 动态加载js文件
function loadJs(file, headElem) {
    var script = document.createElement('script');
    script.src = file;
    script.type = 'text/javascript';
    if (headElem) headElem.appendChild(script);
    else document.getElementsByTagName('head')[0].appendChild(script);
}

/**
 * 初始化文件上传
 * @param valueId 存放附件id的id
 * @param fildRegisterId 注册组件的id
 * @param fileType 文件上传类型 []
 * @param validatorField 校验字段
 */
function initUploadFileInfo(valueId, fildRegisterId, fileType, validatorField) {
    let sfzZIds = $("#" + valueId).val();
    let sfzZImgs = [];
    let sfzZConfig = [];
    if (sfzZIds) {
        if (sfzZIds.indexOf(',') > 0) {
            let sfzZIdsSplit = sfzZIds.split(',');
            sfzZIdsSplit.forEach(item => {
                let data = getFileName(item);
                let fileUrl = ctx + "common/file/download/" + data.fileId;
                sfzZImgs.push(getPreviewUrl(fileUrl,data.fileName));
                //添加配置项
                let obj = {};
                obj.url = ctx + "common/file/delOneFile";
                obj.key = item;
                obj.caption = data.fileName;
                obj.size = data.fileSize;
                sfzZConfig.push(obj);
            })
        } else {
            let data = getFileName(sfzZIds);
            let fileUrl = ctx + "common/file/download/" + data.fileId;
            sfzZImgs.push(getPreviewUrl(fileUrl,data.fileName));
            //添加配置项
            let obj = {};
            obj.url = ctx + "common/file/delOneFile";
            obj.key = sfzZIds;
            obj.caption = data.fileName;
            obj.size = data.fileSize;
            sfzZConfig.push(obj);
        }
    }
    initDeclaredeclareUpload(sfzZImgs, sfzZConfig, valueId, fildRegisterId, fileType, validatorField);
}

/**
 * 
 * @param preview 文件列表
 * @param config  配置项
 * @param valueId 存放附件id的id
 * @param fildRegisterId 注册组件的id
 * @param fileType 文件上传类型 []
 * @param validatorField 验证id
 */
function initDeclaredeclareUpload(preview, config, valueId, fildRegisterId, fileType, validatorField) {
    let fileIds = [];
    let htmlFileid = $("#" + valueId).val();
    if (htmlFileid) {
        if (htmlFileid.indexOf(',') > -1) {
            let idsdb = htmlFileid.split(',');
            fileIds = fileIds.concat(idsdb);
        } else {
            fileIds.push(htmlFileid);
        }
    }
    let map = new Map();
    let type = '';//文件提示限制类型
    if (fileType && fileType.length > 0) {
        type = fileType.join(',')
    } else {
        type = ".doc, .docx, .xls, .xlsx, .pdf";
    }
    $("#" + fildRegisterId).fileinput({
        theme: "explorer",
        uploadUrl: ctx + "common/file/upload", //上传的地址
        minFileCount: 0,
        maxFileCount: 20,
        // overwriteInitial: false,
        // showUpload: false,
        // showCaption: false,
        // showRemove: false,
        // showCaption: true,
        showPreview: false,
        // dropZoneEnabled: false,
        // showBrowse: true,
        // autoReplace: true,
        // browseOnZoneClick: false,
        language: 'zh',
        dropZoneTitle: '拖拽文件到这里，或点击此处选择文件 &hellip;<br>支持多文件同时上传',
        dropZoneClickTitle: '<br>支持文件类型' + type,
        validateInitialCount: true,
        allowedFileExtensions: (undefined != fileType && fileType.length > 0) ? fileType : ['jpg', 'doc', 'docx', 'xls', 'xlsx', 'pdf'],
        msgInvalidFileExtension: '上传文件类型错误"{name}".只能上传"{extensions}"类型的文件',
        initialPreview: preview,//初始预览内容
        // previewSettings: {
        //     image: { width: 'auto', height: 'auto', 'max-width': '100%', 'max-height': '100%' },
        //     office: { width: '100%', height: '100%', 'max-width': '100%', 'max-height': '100%' },
        //     pdf: { width: '100%', height: '100%' },
        // },
        initialPreviewAsData: true,
        initialPreviewConfig: config,
        // initialPreviewConfig: [
        //     {caption: "Business 1.jpg", size: 762980, url: "/site/file-delete", key: 11},
        //     {caption: "Business 2.jpg", size: 823782, url: "/site/file-delete", key: 13, previewAsData: false},
        //     {caption: "PDF Sample.pdf", size: 8000, url: "/site/file-delete", key: 14, type: "pdf"},
        //     {caption: "Lorem Ipsum.txt", type: "text", size: 1430, url: "/site/file-delete", key: 12},
        //     {type: "video", size: 375000, filetype: "video/mp4", caption: "Krajee Sample.mp4", url: "/site/file-delete", key: 15},
        // ],
        preferIconicPreview: true, // this will force thumbnails to display icons for following file extensions
        // previewFileIcon: '<i class="glyphicon glyphicon-file"></i>',
        previewFileIconSettings: { // configure your icon file extensions
            'doc': '<i class="fa fa-file-word-o text-primary" ></i>',
            'xls': '<i class="fa fa-file-excel-o text-success"></i>',
            'ppt': '<i class="fa fa-file-powerpoint-o text-danger"></i>',
            'pdf': '<i class="fa fa-file-pdf-o text-danger"></i>',
            'zip': '<i class="fa fa-file-archive-o text-muted"></i>',
            'htm': '<i class="fa fa-file-code-o text-info"></i>',
            'txt': '<i class="fa fa-file-text-o text-info"><img src="/img/excel.png"/></i>',
            'mov': '<i class="fa fa-file-movie-o text-warning"></i>',
            'mp3': '<i class="fa fa-file-audio-o text-warning"></i>',
            'jpg': '<i class="fa fa-file-photo-o text-danger"></i>',
            'gif': '<i class="fa fa-file-photo-o text-muted"></i>',
            'png': '<i class="fa fa-file-photo-o text-primary"></i>'
        },
        previewFileExtSettings: { // configure the logic for determining icon file extensions
            'doc': function (ext) {
                return ext.match(/(doc|docx)$/i);
            },
            'xls': function (ext) {
                return ext.match(/(xls|xlsx)$/i);
            },
            'ppt': function (ext) {
                return ext.match(/(ppt|pptx)$/i);
            },
            'zip': function (ext) {
                return ext.match(/(zip|rar|tar|gzip|gz|7z)$/i);
            },
            'htm': function (ext) {
                return ext.match(/(htm|html)$/i);
            },
            'txt': function (ext) {
                return ext.match(/(txt|ini|csv|java|php|js|css)$/i);
            },
            'mov': function (ext) {
                return ext.match(/(avi|mpg|mkv|mov|mp4|3gp|webm|wmv)$/i);
            },
            'mp3': function (ext) {
                return ext.match(/(mp3|wav)$/i);
            },
        }
    }).on("filebatchselected", function (event, files) {
        $(this).fileinput("upload");
    }).on('fileuploaded', function (event, data, extraData) {
        fileIds.push(data.response.data);
        map.set(extraData, data.response.data);
        fileOperation(fileIds, 'add', '', valueId);
    }).on('filesuccessremove', function (event, key) {
        let id = map.get(key);
        fileOperation(fileIds, 'del', id + '', valueId);
    }).on('filedeleted', function (event, key) {
        fileOperation(fileIds, 'del', key + '', valueId);
    });
}

/**
 * 根据文件id获取文件名称
 * @param fileId
 */
function getFileName(fileId) {
    let obj = {}
    $.ajax({
        method: 'post',
        async: false,
        url: ctx + 'common/file/fileInfo',
        data: { "fileId": fileId },
        success: function (res) {
            if (res.code === 0) {
                obj = res.data
            }
        }
    })
    return obj;
}

/**
 *  文件id赋给隐藏字段
 * @param ids 文件id
 * @param type del删除 add添加
 * @param key 要删除的id
 */
function fileOperation(ids, type, key, id) {
    if (type === 'del') {
        let index = ids.indexOf(key);
        if (index > -1) {
            delete ids[index];
        }
    }
    let values = '';
    let i = 0;
    //拼接字符串
    ids.forEach(item => {
        if (i > 0) {
            values += "," + item
        } else {
            values += item
        }
        if (item) {
            i++
        }
    });
    $("#" + id).val(values).change();
}

/** 页面常量 */
page_constants = {
    ALL_USER: "全员",
    KKFILEVIEW_URL: "http://localhost:8012",
};

function previewFile(fileId,fileName) {

    var originUrl = 'http://localhost:8088/common/file/download?fileId=' + fileId //要预览文件的访问地址(下载流)
    var previewUrl = originUrl + '&fullfilename=' + fileName
    var url = page_constants.KKFILEVIEW_URL + '/onlinePreview?url=' + encodeURIComponent(Base64.encode(previewUrl))
    $.modal.openTab("预览详情", url)
}

